
#blk=(40 80 160 320 640)
#blkx=( 1 1 2 2 4 4 8 8  16 16 32 32 64)
#blky=( 2 4 2 4 4 8 8 16 16 32 32 64 64)
#sblkx=(1 1 2 2 4 4 4 4  4  4  4  4  4)
#sblky=(2 4 2 4 4 4 4 4  4  4  4  4  4)
blkx=( 1 1 2 4 4 8 8  16 16 32 64)
blky=( 2 4 4 4 8 8 16 16 32 32 64)
sblkx=(1 1 2 4 4 4 4  4  4  4  4)
sblky=(2 4 4 4 4 4 4  4  4  4  4)

file=temp.log
result_file=result.log

rm $file $result_file 

for((i=0;i<11;i++))
do
  sed s/@BLKX/${blkx[$i]}/g makefile_temp > temp
  sed s/@BLKY/${blky[$i]}/g temp > temp2
  sed s/@SBLKX/${sblkx[$i]}/g temp2 > temp
  sed s/@SBLKY/${sblky[$i]}/g temp > makefile_test_$i
  
  #sed s/#test[$i]#//g makefile_temp > makefile_test_$i
  #sed s/#@test[$i]#//g makefile_temp > makefile_test_$i
  cp -f makefile_test_$i makefile
  make clean
  make reuse_1_1
  #echo ${blk[$i]}
  bsub -I -b -q q_sw_expr -n 1 -cgsp 64 -host_stack 1024 -share_size 6000 -o $file ./3d7p_reuse_1_1 64 100
done

rm temp temp2

echo total_graph_build >> $result_file
grep -n "total_graph_build" $file | awk {'print $2'} >> $result_file

echo total_graph_exec >> $result_file
grep -n "total_graph_exec" $file | awk {'print $2'} >> $result_file

echo total_time >> $result_file
grep -n "total_time" $file | awk {'print $2'} >> $result_file

echo mutex_file >> $result_file   
grep -n "ain core mutex fa" ./$file | awk '{print $6}' >> $result_file
echo total_mutex >> $result_file
grep -n "re mutex success co" ./$file| awk '{print $6}' >> $result_file


cat $result_file

mv $file $1_$file
mv $result_file $1_${result_file}
